from typing import Literal, List, Union, TypedDict, Type, Optional, Any


class putProductPhotoDTO(TypedDict):
    photo: str


class putAttributesVO(TypedDict):
    attributeName: str
    attributeNameValue: str


class putProductDiffPriceModel(TypedDict):
    orgId: int
    price: int


class putProductSpecificationDTO(TypedDict):  #!上传规格模型
    """上传规格模型"""

    packingSpecificationValue: int
    packingSpecificationUnit: str


class putProductSpecificationDTOmin(putProductSpecificationDTO):  #!上传最小规格模型
    """上传最小规格模型"""

    minSpecificationValue: int
    minSpecificationUnit: str


class putCategoryModel(TypedDict):
    id: int
    name: str


class putdangerousDto(TypedDict):  #!上传规格模板
    casNo: str


class rjPutParamsModel(TypedDict, total=False):  #!锐竞商品上传参数
    """锐竞商品上传参数"""

    id: int  # 商品id
    productNum: str  # 商品货号
    price: float
    name: str
    specification: str
    status: Literal[2, 3]
    categoryId: int
    brandId: int
    sku: int
    unit: str
    desc: Optional[str]
    photos: putProductPhotoDTO
    # priceDifferents: Optional[PutProductDiffPriceModel]
    deliveryTime: Literal[1, 7, 14, 21, 30, 60, 61, -1]
    attributes: Optional[List[putAttributesVO]]
    productSpecificationDTO: Union[
        putProductSpecificationDTO, putProductSpecificationDTOmin, None
    ]
    carryFeeTemplateId: int
    dangerousDto: putdangerousDto
    directoryPrice: int


class categoryElement(TypedDict):
    id: int
    name: str
    parentId: Optional[int]


class productSpecificationDTO(TypedDict):
    packingSpecificationValue: float
    packingSpecificationUnit: str
    minSpecificationValue: float
    minSpecificationUnit: str


class brandModel(TypedDict):
    id: int
    name: str
    cname: str
    ename: str
    logo: str
    manufacture: str


class dangerousDto(TypedDict):
    type: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    casNo: str


class rjExportDescDataModel(TypedDict):  #!锐竞导出目录简要数据模板
    """锐竞导出目录简要数据模板"""

    id: int
    brandName: str
    brandId: int
    categoryId: int
    photo: str
    code: str
    name: str
    sku: int
    unit: str
    supplierName: str
    supplierId: Optional[int]
    status: int
    specification: str
    price: float
    casNo: str
    dangerousType: int
    indexNum: int
    rejectComment: Optional[str]


class rjExportDetailDataModel(TypedDict, total=False):  #!锐竞导出详细数据模板
    """锐竞导出详细数据模板"""

    id: int
    productNum: str
    saleAmount: int
    price: float
    name: str
    photo: str
    specification: str
    status: Literal[2, 3]
    category: List[categoryElement]
    productSpecificationDTO: Union[
        putProductSpecificationDTO, putProductSpecificationDTOmin, None
    ]
    dangerousDto: Optional[dangerousDto]
    brand: brandModel
    sku: int
    unit: str
    desc: Optional[str]
    photos: putProductPhotoDTO
    priceDifferents: Optional[putProductDiffPriceModel]
    deliveryTime: Literal[1, 7, 14, 21, 30, 60, 61, -1]
    carryFeeTemplateId: int
    attributes: Optional[List[putAttributesVO]]


class categorieModel(TypedDict):
    id: int
    name: str
    sequence: Optional[int]
    parentId: int
    level: int
    path: Optional[str]
    status: int
    reimbursementExpenseType: int
    inboundType: int


class specificationModel(TypedDict):
    productName: str
    goodCode: str
    remainCanBuy: int
    specification: str
    unit: str
    photo: str
    activityStatus: int
    hasActivity: bool
    supplierId: int
    productId: int
    sku: int
    unifyPrice: float
    price: float
    priceSourceTag: int


class priceTendencyModel(TypedDict):
    date: str
    price: float


class shopServiceSuperiorityModel(TypedDict):
    materialContent: str
    materialType: int


class rjReptilesCatalogueModel(
    TypedDict, total=False
):  #!锐竞平台爬取的商品目录信息模板
    """锐竞平台爬取的商品信息模板"""

    supplierName: str
    specification: str
    goodsSpecification: str
    photo: str
    deliveryTime: Optional[str]
    saleAmount: int
    id: int
    supplierFlag: int
    level: Optional[str]
    protocol: int
    price: int
    minPrice: int
    brandName: str
    supplierId: int
    categoryId: int
    name: str
    searchAfter: Optional[str]
    casNo: str
    dangerousTag: str
    agencyName: str
    productNum: str
    detailPhotos: List[str]
    commentCount: Optional[int]
    attrItems: List[str]
    reagent100: int
    rs: int
    rh: float
    rsh: Optional[str]
    deliveryProxyOn: Optional[str]
    suppDeliveryProxyLabels: Optional[str]
    topRightImageTag: Optional[str]
    carryFeeId: Optional[str]
    activityId: Optional[str]
    rt: Optional[str]
    concentration: Optional[str]
    suppVipTag: bool
    negotiatedPrice: bool
    groupBuying: bool
    activityPrice: bool


class rjReptilesModel(TypedDict):  #!锐竞平台爬取的商品信息模板
    """锐竞平台爬取的商品信息模板"""

    standardId: int
    supplierId: int
    storeName: str
    categories: List[categorieModel]
    category: List[categorieModel]
    categoryId: int
    categoryName: Optional[str]
    name: str
    specifications: List[specificationModel]
    specification: str
    goodsSpecification: str
    sku: int
    unit: str
    code: str
    originalPrice: Optional[float]
    price: float
    marketPrice: Optional[float]
    photo: str
    casNo: str
    status: int
    saleAmount: int
    description: str
    supplierName: str
    brandId: int
    brandName: str
    deliveryTime: int
    dangerousType: int
    dangerousTag: str
    regulatoryType: int
    orgPrice: Optional[float]
    photos: List[str]
    video: str
    deleted: bool
    haveNegotiatedPrice: Optional[float]
    haveActivityPrice: Optional[float]
    hasActivity: bool
    quantity: int
    categoryDirectoryId: Optional[int]
    showOriginalPrice: Optional[float]
    enter: bool
    unifyPrice: float
    restricted: bool
    priceTendencyList: List[priceTendencyModel]
    chemicalSafetyCardUrl: Optional[str]
    protocol: int
    agencyName: Optional[str]
    attributes: Optional[putAttributesVO]
    lastSaleAmount: int
    activityProduct: None
    shopServiceSuperiority: shopServiceSuperiorityModel
    shopBrandSuperiority: None
    experimentList: List[Any]
    userInterested: Optional[Any]
    carryFee: Optional[Any]
    carryFeeMsg: Optional[Any]
    priceSourceTag: int
    remainCanBuy: int
    suppRemainCount: int
    disable: bool
    disableMessage: str
    warnMessage: str
    limitType: Optional[int]
    blacklistType: Optional[List]
    blacklistWord: str
    blacklistTooltip: str
    topRightImageTag: Any
    ruleRemindMsg: str
    adId: Optional[int]
    negotiatedPrice: Optional[float]


class rjUpdateProductModel(TypedDict, total=False):  #!锐竞官方接口修改商品信息修改模板
    productNum: str  #! 商品货号（必须要具有商品唯一性）
    price: int  # * 统一售价, 保留两位小数(若商品品牌已签署平台协议价, 则售价不能高于“协议上限折扣价”(协议上限折扣价 = 目录价 * 协议价上限折扣))
    directoryPrice: int  # *目录价, 保留两位小数(若商品品牌签署了协议价必传, 未签署选传)
    sku: int  # *库存数量
    unit: str  # *销售单位, 不可自定义, 必须使用平台的标准销售单位 (数据来源: 查询标准单位、包装规格和最小包装规格列表的接口/openapi/product/queryUnitAndSpecification)
    desc: str  # *	商品介绍 (支持富文本格式)
    photos: List[
        putProductPhotoDTO
    ]  # *商品图库 (程序会截取第一张图为主图 , 一共不能超过5张图) , 见下方ProductPhotoDTO
    deliveryTime: int  # *货期[[[1	现货],[7	1周内],[14	2周],[21	3周],[30	1个月],[60	2个月],[61	2个月以上],[-1	咨询供应商客服]]]
    carryFeeTemplateId: int  # *运费模版Id, 全国包邮不用传(数据来源 : 查询商家所有运费模板/openapi/product/findTemplate)
    attributes: List[putAttributesVO]  # *商品属性模型 , 见下方AttributesVO


class rjObjectParamModel(TypedDict):  #!商品信息传输模板
    """商品信息传输模板"""

    Object: Union[rjExportDetailDataModel, rjReptilesModel, rjPutParamsModel]
    Type_: Literal["RJExportDataModel", "RJReptilesModel", "RJPutParamsModel"]


class SearchParametersModel(TypedDict, total=False):  #!锐竞爬虫原始搜索参数,全参
    """锐竞爬虫原始搜索参数,全参"""

    brandIds: List[int]
    brandName: str
    casNo: str
    city: str
    orgId: str
    pageSize: int
    pageNo: str
    sort: int
    key: str
    maxPrice: Optional[str]
    minPrice: Optional[str]
    categoryIds: List[int]
    searchFlag: int
    supplierIds: List[int]
    supplierName: str
    flag: int
    relationCategoryOn: bool
    useDefaultSearchMode: bool


class ReptilesParamsModel(
    TypedDict, total=False
):  #!锐竞爬虫导入`rjReptilesParams()`的必要参数,即`SearchParameters`class实例
    """锐竞爬虫导入`rjReptilesParams()`的必要参数,即`SearchParameters`实例"""

    key: str
    brandIds: List[int]
    supplierIds: List[int]
    sort: int
    pageSize: int
    relationCategoryOn: bool


class SearchListModel(TypedDict, total=False):
    """获取商品列表搜索参数
    状态(2:草稿，3:上架，4下架，5强制下架，12待审核，15已驳回)
    """

    brandIds: List[int]
    categoryId: int
    status: int
    page: int
    size: int


class CategoryAttributeModel(TypedDict):
    categoryId: List[int]
    isSale: Literal[0, 1]
